import request from '@/utils/request'
import type { PmTimeTrackingVO, PmTimeStatsVO } from '@/api/pm/types'

export function listTime(params: any) {
  return request({
    url: '/pm/time/list',
    method: 'get',
    params
  })
}

export function startTime(data: Partial<PmTimeTrackingVO>) {
  return request({
    url: '/pm/time/start',
    method: 'post',
    data
  })
}

export function stopTime(id: string | number) {
  return request({
    url: `/pm/time/stop/${id}`,
    method: 'post'
  })
}

export function saveTime(data: Partial<PmTimeTrackingVO>) {
  return request({
    url: '/pm/time',
    method: 'post',
    data
  })
}

export function delTime(ids: (string | number)[]) {
  return request({
    url: `/pm/time/${ids.join(',')}`,
    method: 'delete'
  })
}

export function getUserTimeStats(params: { userId: string | number, startDate: string, endDate: string }) {
  return request({
    url: '/pm/time/stats/user',
    method: 'get',
    params
  })
}

export function getProjectTimeStats(params: { projectId: string | number, startDate: string, endDate: string }) {
  return request({
    url: '/pm/time/stats/project',
    method: 'get',
    params
  })
}


